package cn.niit.smbms.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Alias("User")
public class User extends BaseEntity {
    @NotBlank(message = "用户编码不能为空！")
    @Length(min = 3, max = 6, message = "用户编码长度必须在3 ~ 6 位之间")
    private String userCode;
    @NotBlank(message = "用户姓名不能为空！")
    @Length(min = 2, max = 10, message = "用户姓名长度必须在2 ~ 10 位之间")
    private String userName;
    @Length(min = 3, max = 10, message = "用户密码长度必须在 3 ~ 10 位之间")
    private String password;
    @NotNull(message = "请选择性别")
    private Integer gender;
    @NotBlank(message = "请选择出生日期！")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private String birthday;
    @Length(min = 11, max = 11, message = "电话长度必须为 11 位")
    private String phone;
    @NotNull(message = "请填写地址")
    private String address;
    @NotNull(message = "请选择角色")
    private Integer userRole;
    /*最后一次登录时间*/
    private Date loginTime;
}
